export const curry = function (fn: Function, ...a: any) {
    debugger
    const args = Array.prototype.slice.call(arguments, 1)
    return function (...b: any) {
        debugger
        const newArgs = args.concat(Array.prototype.slice.call(arguments))
        return fn.apply(this, newArgs)
    }
}

export const progressCurry = function (fn: Function, ...a: any) {
    const _this = this
    const len = fn.length
    const args = a || []
    debugger
    return function (...b: any) {
        debugger
        const _args = Array.prototype.slice.call(arguments)
        Array.prototype.push.apply(args, _args)
        if (_args.length < len) {
            return progressCurry.call(_this, fn, _args)
        }
        return fn.apply(this, _args)
    }
}

export const add = function (...a: any) {
    debugger
    var _args = Array.from(arguments)
    var _add: any = function () {
        _args = _args.concat(Array.from(arguments))
        return _add
    }
    _add.toString = function () {
        return _args.reduce((pre, cur) => pre + cur, 0)
    }
    return _add
}